package jisuanke;

import java.util.Scanner;

public class 跳跃游戏二 {

    static Node[] nodes = new Node[100];
    static int[] book = new int[101];
    static int head=0 , tail=1;
    static int p = 0;
    static int[] a;
    static int n;
    static int dis=0;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        n = sc.nextInt();
        a = new int[n];
        for(int i=0;i<n;i++){
            a[i] = sc.nextInt();
        }
        //初始化堆栈
        for(int i=0;i<100;i++){
            nodes[i] = new Node();
        }
        nodes[head].dis = 0;
        nodes[head].p = 0;
        bfs();
        System.out.println(nodes[n-1].dis);
    }

    public static void bfs(){
        while (head<tail){
            if(tail == n+1){
                break;
            }
            for(int i=1;i<=a[head];i++){
                p++;
                //判断走过
                if(book[p]==1 || p>=n){
                    p--;
                    continue;
                }
                nodes[tail].dis = nodes[head].dis+1;
                nodes[tail].p = p;
                book[tail] = 1;
                tail++;
            }
            head++;
            p = head;
        }
    }
}

class Node{
    int dis;
    int p;
}
